#if !defined(SM__COLLIDE_H)
#define SM__COLLIDE_H

#include "SDL.h"
#include "swagme.h"

class TouchableObject;
class DummyWall;

struct CollisionMap 
{
  // this becomes an array of pointers
  TouchableObject** map;
  unsigned int height;
  unsigned int width;
  unsigned int cellInPixels;

  TouchableObject* atCol(int x, int y);
  TouchableObject* atMap(int x, int y);
  // returns true if the region defined by the SDL_Rect is empty
  bool isEmptyCol(const SDL_Rect& rc);
  bool isEmptyMap(const SDL_Rect& rc);

  void addTouchableObject(TouchableObject*);
  void removeTouchableObject(TouchableObject*);

  DummyWall* theWall;

  // TODO: eventually make proper constructor/deconstructors and move
  // that code out of Game
//  CollisionMap(DummyWall& wall);
//  ~CollisionMap();
};

struct CollisionEvent {
  sm_cdr_result result;
  TouchableObject* cdrObject;
  unsigned char cdrObjectType;
  Sint16 finalX, finalY;
};

// used references instead of pointers to prevent any memory leaks
// and ownership questions...
void moveRectWithCdr(const CollisionMap& colMap,
                     const SDL_Rect& inPosBegin,
                     const SDL_Rect& inPosEnd,
                     CollisionEvent& outEvent,
                     bool bDebug = false);

#endif // SM__COLLIDE_H
